package com.zbkj.crmeb.enums;

/**
 * @Author: Rede
 * @DateTime: 2024-07-12 10:29
 * @Description:
 */
/**
 * <p>
 * 类描述: 开关枚举
 * </p>
 */
public enum SwitchEnum {

    /**
     * 否
     **/
    CLOSE(0, "否"),

    /**
     * 是
     **/
    OPEN(1, "是");

    /**
     * code
     **/
    private Integer code;

    /**
     * msg
     **/
    private String msg;

    /**
     * @return the code
     */
    public Integer getCode() {
        return code;
    }

    /**
     * @return the msg
     */
    public String getMsg() {
        return msg;
    }

    /**
     * @param code code
     * @param msg  msg
     */
    SwitchEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 根据code查询信息
     *
     * @param code 编码
     * @return 信息
     */
    public static String getMsgByCode(Integer code) {
        for (SwitchEnum status : SwitchEnum.values()) {
            if (status.getCode().equals(code)) {
                return status.getMsg();
            }
        }
        return "";
    }

    /**
     * 是否开启
     */
    public static boolean isOpen(Integer state) {
        return SwitchEnum.OPEN.getCode().equals(state);
    }

    /**
     * 是否关闭
     */
    public static boolean isClose(Integer state) {
        return SwitchEnum.CLOSE.getCode().equals(state);
    }
}
